﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace AC
{
	public interface ITextMeasurer
	{
		SizeF MeasureString(string text, Font font);
	}

	public class TextMeasurer : ITextMeasurer
	{
		private readonly Image _fakeImage;
		private readonly Graphics _graphics;
		private Font _font;
		public TextMeasurer()
		{
			_fakeImage = new Bitmap(1, 1);
			_graphics = Graphics.FromImage(_fakeImage);
			_font = new Font("Tahoma", 8.25F, FontStyle.Regular);
		}

		public TextMeasurer(Font _font)
		{
			_fakeImage = new Bitmap(1, 1);
			_graphics = Graphics.FromImage(_fakeImage);
			this._font = _font;
		}

		public SizeF MeasureString(string text)
		{
			return _graphics.MeasureString(text, this._font);
		}

		public SizeF MeasureString(string text, Font font)
		{
			return _graphics.MeasureString(text, font);
		}
	}
}
